package com.example.delegatestrategy.demo;

import java.util.HashMap;
import java.util.Map;

/**
 * @author godShan
 * @Description:
 * @date 2019/5/8 10:06
 */
public class AwardFactory {

    private final static Map<String, Award> map = new HashMap<>();

    static {
        map.put(AwardKey.AMX, new AMXAward());
        map.put(AwardKey.ML, new MLAward());
        map.put(AwardKey.WW, new WWAward());
        map.put(AwardKey.YL, new YLAward());
    }

    public static Award getInstance(String awardKey) {
        if (!map.containsKey(awardKey)) {
            return map.get(AwardKey.DEFAULT);
        }
        return map.get(awardKey);
    }


    private interface AwardKey{
        String ML = "ML";
        String WW = "WW";
        String AMX = "AMX";
        String YL = "YL";
        String DEFAULT = "ML";
    }

}
